<template>
  <div class="avue-crud">
    <el-table :data="dataList" :height="tableHeight==null?'calc((100vh - 80px - 70px) / 2 - 60px)':tableHeight" border>
      <!-- <el-table-column label="审批编号" prop="ywMainCode" align="center" min-width="150px"></el-table-column>
      <el-table-column label="审批名称" prop="ywTitle" header-align="center" align="left" min-width="250px"></el-table-column> -->
      <el-table-column label="流程名称" prop="taskName" align="center" width="200px" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-if="scope.row.processDefKey == 'HE_YJHT'">业绩合同</span>
          <span v-else-if="scope.row.processDefKey == 'HE_JXZDRW'">重点任务</span>
          <span v-else-if="scope.row.processDefKey == 'HE_GZRWS'">工作任务书</span>
          <span v-else-if="scope.row.processDefKey == 'RCKH_SJLC'">精准激励</span>
          <span v-else-if="scope.row.processDefKey == 'RCKH_ZBLC'">精准激励</span>
		  <span v-else-if="scope.row.processDefKey == 'TJFX_EJLD'">评分汇总</span>
          <span v-else-if="scope.row.processDefKey == 'TJFX_PFHZ'">评分汇总</span>
          <span v-else>其他</span>
        </template>
      </el-table-column>
      <el-table-column label="当前节点" prop="taskName" align="center" width="200px" show-overflow-tooltip></el-table-column>
      <el-table-column label="发起人" prop="userName" align="center" width="80px" show-overflow-tooltip></el-table-column>
      <el-table-column label="任务数量" prop="cou" align="center" width="90px" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-if="scope.row.cou == 0">1</span>
          <span v-else>{{scope.row.cou}}</span>
        </template>
      </el-table-column>
      <el-table-column label="接收时间" prop="time" align="center" width="150px" show-overflow-tooltip>
        <template slot-scope="scope">{{$moment(scope.row.time).format("YYYY-MM-DD HH:mm")}}</template>
      </el-table-column>
      <el-table-column label="操作" align="center" min-width="100">
        <template slot-scope="scope">
          <!-- <el-button  type="primary" plain @click="handleDialog(scope.row)">审批办理</el-button> -->
           <el-button  type="primary" plain @click="shenhe(scope.row)">审批办理</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div v-if="true" class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                     :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background
                     layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </div>
    <workflow ref="workflow" @refreshDataList="getDataList" @refreshTableData="getDataList"></workflow>
  </div>
</template>

<script>
import {wddbpage} from "@/api/workflow/wfywmain";
import workflow from '@/views/workflow/apply/index'

import store from '@/store'
import {
  mapGetters
} from 'vuex'

export default {
  data() {
    return {
      dataForm: {
        key: ''
      },
      dataFormSzbg: {
        id: 0,
        szbgFjmc: '',
        szbgFjlx: '',
        szbgFjdz: '',
        szJzDate: ''
      },
      bgdialogVisible: false,
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      cepinghdgulszbgUploadFormVisible: false,
      headers: {
        Authorization: 'Bearer ' + store.getters.access_token
      },
      bgUrl: ""
    }
  },
  created() {
    this.getDataList();
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  props: {
    tableHeight: {
      type: String,
      default: null
    }
  },
  components: {
    workflow
  },
  methods: {

    shenhe(row){
       if(row.processDefKey=='HE_YJHT'){
         if(row.nodeKey==='ndzb'){
           this.$router.push({path: '/hetongrenwu/hetong/hetongyeji/hetongnd/index'})
         }else if(row.nodeKey==='jgtb'){
           this.$router.push({path: '/hetongrenwu/hetong/hetongtb/hetongjgtb/index'})
         } else if(row.nodeKey==='usertask3' || row.nodeKey==='usertask4' ){
           this.$router.push({path: '/hetongrenwu/hetong/hetongyeji/hetongzbsh/index'})
           //文本审核串行 usertask6 并行usertask7
         }else if(row.nodeKey==='usertask6' || row.nodeKey==='usertask7' ){
           this.$router.push({path: '/hetongrenwu/hetong/hetongyeji/hetongwbsh/index'})
           //合同审核 usertask9 usertask10  myself
         }else if(row.nodeKey==='usertask9' || row.nodeKey==='usertask10'|| row.nodeKey==='myself' ){
           this.$router.push({path: '/hetongrenwu/hetong/hetongqianding/hetongsh/index'})
           //填报审核 usertask11 usertask11b
         }else if(row.nodeKey==='usertask11' || row.nodeKey==='usertask11b'){
           this.$router.push({path: '/hetongrenwu/hetong/hetongtb/hetongtbsh/index'})
           //领导审核 usertask13 usertask14
         }else if(row.nodeKey==='usertask13' || row.nodeKey==='usertask14'){
           this.$router.push({path: '/hetongrenwu/hetong/hetongtb/hetongqtjc/index'})
         }
       }
        if(row.processDefKey=='HE_JXZDRW'){
            if(row.nodeKey==='rwtb'){
                //任务填报
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwcj/renwuNd/index'})
            }else if(row.nodeKey==='rysh'){
                //考核人员审核
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwcj/rwsh/index'})
            }else if(row.nodeKey==='syrqr' || row.nodeKey==='sd'){
                //文本汇总审核
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwcj/wbhz/index'})
            }else if(row.nodeKey==='zp'){
                //自评
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwtb/zp/index'})
            }else if(row.nodeKey==='pj'){
                //他评
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwtb/zdrwpj/index'})
            }else if(row.nodeKey==='qt'){
                //其他奖惩
                this.$router.push({path: '/hetongrenwu/zhongdianrenwu/zhongdianrwtb/qtjc/index'})
            }

        }

        if(row.processDefKey=='HE_GZRWS'){
            if(row.nodeKey==='rwnd'){
                //任务拟定
                this.$router.push({path: '/hetongrenwu/taskBook/bookCreate/bookNd/index'})
            }else if(row.nodeKey==='rwsh'){
                //任务审核
                this.$router.push({path: '/hetongrenwu/taskBook/bookCreate/bookSh/index'})
            }else if(row.nodeKey==='wbsh' || row.nodeKey==='bkhrsh'){
                //文本汇总审核
                this.$router.push({path: '/hetongrenwu/taskBook/bookCreate/bookWbhz/index'})
            }else if(row.nodeKey==='khrzp'){
                //自评
                this.$router.push({path: '/hetongrenwu/taskBook/bookFill/bookZp/index'})
            }else if(row.nodeKey==='usertask11'){
                //他评
                this.$router.push({path: '/hetongrenwu/taskBook/bookFill/bookPj/index'})
            }else if(row.nodeKey==='ldsh'){
                //领导审核
                this.$router.push({path: '/hetongrenwu/taskBook/bookFill/bookLd/index'})
            }

        }


        //专项工作及日常考核新增开始
        if(row.processDefKey=='HE_JXZXGZ'){
            if(row.nodeKey==='qc') {
                this.$router.push({path: '/hetongrenwu/specialWork/createWork/createWork'})
            }else if(row.nodeKey==='qcjlsp' || row.nodeKey==='zbjlsp'|| row.nodeKey==='xbjlsp'){
                this.$router.push({path: '/hetongrenwu/specialWork/workExamine/index'})
            }else if(row.nodeKey==='cyrjlsp') {
                this.$router.push({path: '/hetongrenwu/specialWork/joinPerConfirm/index'})
            }
        }

        if(row.processDefKey=='RCKH_SJLC'){
            if(row.nodeKey==='sjshsjshcx' || row.nodeKey==='sjshsjshbx') {
                this.$router.push({path: '/dailyExamine/eventExamine/eventExamine/index'})
            }
            else if(row.nodeKey==='khyqc') {
                this.$router.push({path: '/dailyExamine/eventExamine/createEvent/index'})
            }
            else if(row.nodeKey==='sjshjxwzysh' || row.nodeKey==='sjshwyhcx'|| row.nodeKey==='sjshwyhbx'){
                this.$router.push({path: '/dailyExamine/eventExamine/eventReview/index'})
            }else if(row.nodeKey==='khyqr') {
                this.$router.push({path: '/dailyExamine/eventExamine/resultsConfirm/index'})
            }
        }
        if(row.processDefKey=='RCKH_ZBLC'){
            if(row.nodeKey==='zbkhycj') {
                this.$router.push({path: '/dailyExamine/targetExamine/createAssessment/index'})
            }
            else if(row.nodeKey==='khzbnd') {
                this.$router.push({path: '/dailyExamine/targetExamine/indicatorFormulation/index'})
            }
            else if(row.nodeKey==='khzbshcx' || row.nodeKey==='khzbshbx'){
                this.$router.push({path: '/dailyExamine/targetExamine/indexReview/index'})
            }
            else if(row.nodeKey==='sjkhwyhzy'||row.nodeKey==='sjkhwyhcx' || row.nodeKey==='sjkhwyhbx') {
                this.$router.push({path: '/dailyExamine/targetExamine/indexExamine/index'})
            }
            else if(row.nodeKey==='khyfqtb') {
                this.$router.push({path: '/dailyExamine/InitiateFilling/InitiateFilling/index'})
            }
            else if(row.nodeKey==='khzbtb') {
                this.$router.push({path: '/dailyExamine/InitiateFilling/resultFilling/index'})
            }
            else if(row.nodeKey==='khjgtbcx' || row.nodeKey==='khjgtbbx'){
                this.$router.push({path: '/dailyExamine/InitiateFilling/fillingAndApproval/index'})
            }
            else if(row.nodeKey==='khldhz'||row.nodeKey==='khldshcx' || row.nodeKey==='khldshbx') {
                this.$router.push({path: '/dailyExamine/InitiateFilling/resultAudit/index'})
            }
            else if(row.nodeKey==='khbkhrqr') {
                this.$router.push({path: '/dailyExamine/InitiateFilling/resultsConfirm/index'})
            }
        }

        //专项工作及日常考核新增结束
		//评分汇总开始
        if(row.processDefKey=='TJFX_PFHZ'){
             if(row.nodeKey==='bmhzcj') {
                this.$router.push({path: '/statisticsanalysis/departSummary/index'})
            }
            else if(row.nodeKey==='bmldspcx' || row.nodeKey==='bmldspbx'){
                this.$router.push({path: '/statisticsanalysis/leaderReview/index'})
            }
        }

        if(row.processDefKey=='TJFX_EJLD'){
            if(row.nodeKey==='pfzycj') {
                this.$router.push({path: '/statisticsanalysis/leaderSummary/index'})
            }
            else if(row.nodeKey==='pfzyhz') {
                this.$router.push({path: '/statisticsanalysis/commissionerSummary/index'})
            }
            else if(row.nodeKey==='pfldshfg' || row.nodeKey==='pfldshcx'||row.nodeKey==='pfldshbx'){
                this.$router.push({path: '/statisticsanalysis/secondaryLeaderReview/index'})
            }
        }
        //评分汇总结束
    },

    formater(row, column, cellValue, index) {
      if (cellValue) {
        return this.$moment(cellValue).format("yyyy-MM-DD HH:mm");
      } else {
        return cellValue;
      }
    },
    // 获取数据列表 预览分页查询使用
    getDataList() {
        this.dataListLoading = true
        wddbpage(Object.assign({
            current: this.pageIndex,
            size: this.pageSize,
            key:"HE_GZRWS,HE_JXZDRW,HE_JXZXGZ,HE_YJHT,HE_ZDRW,HE_ZXGZ,RCKH_SJLC,RCKH_ZBLC,TJFX_PFHZ,TJFX_EJLD"
        })).then(response => {
            this.dataList = response.data.data.records;
            this.totalPage = response.data.data.total;
            this.dataListLoading = false;
        })

    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    handleDialog(r) {
      this.$refs.workflow.open(r.ywId)
    }
  }
}

</script>
